<?php /*a:1:{s:63:"D:\web\wwwroot\tp5.1\public/../app/admin\view\arctype\edit.html";i:1517882306;}*/ ?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>表单</title>
    <link rel="stylesheet" href="/static/frame/layui/css/layui.css">
    <link rel="stylesheet" href="/static/frame/static/css/style.css">
    <link rel="icon" href="/static/frame/static/image/code.png">
</head>
<body class="body">

<form class="layui-form" action="" method="post" id="editform">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">分类名称</label>
            <div class="layui-input-inline">
                <input type="tel" name="title" lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input" value="<?php echo htmlentities($info['title']); ?>">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">上级分类</label>
        <div class="layui-input-inline">
            <select name="pid" lay-verify="required" lay-search="">
                <option value="0">顶级分类</option>
                <?php foreach($typename as $key=>$vo): ?>
                <option value="<?php echo htmlentities($vo['id']); ?>" <?php echo $typepid==$vo['id'] ? 'selected'  :  ''; ?> <?php echo $info['id']==$vo['id'] ? 'disabled="disabled"'  :  ''; ?>><?php echo $vo['_name']; ?></option>
                <?php endforeach; ?>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">关键词</label>
        <div class="layui-input-block">
            <input type="text" name="keywords" class="layui-input" value="<?php echo htmlentities($info['keywords']); ?>">
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">描述</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入内容" name="description" class="layui-textarea"><?php echo htmlentities($info['description']); ?></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">图片上传</label>
        <div class="layui-input-inline">
            <input type="text" name="type_img" class="layui-input" id="typeimg" value="<?php echo htmlentities($info['type_img']); ?>" readonly="readonly">
        </div>
        <div class="layui-input-inline">
            <button type="button" class="layui-btn layui-btn-danger" id="test7"><i class="layui-icon"></i>上传图片</button>
            <div class="layui-inline layui-word-aux">
              这里以限制 500KB 为例
            </div>
        </div>
    </div>    

    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            <input type="radio" name="status" value="1" title="开启" <?php echo !empty($info['status']) ? 'checked=""'  :  ''; ?>>
            <input type="radio" name="status" value="0" title="禁用" <?php echo !empty($info['status']) ? ''  :  'checked=""'; ?>>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
<?php if(!(empty($info) || (($info instanceof \think\Collection || $info instanceof \think\Paginator ) && $info->isEmpty()))): ?>
  <input type="hidden" name="id" value="<?php echo htmlentities($info['id']); ?>">
<?php endif; ?>
</form>
<!-- 通用-970*90 -->


<script src="/static/frame/layui/layui.js" charset="utf-8"></script>
<script src="/static/admin/js/comm.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'upload', 'laydate'], function(){
        var form = layui.form
                ,layer = layui.layer
                ,upload = layui.upload
                ,$ = layui.$ //重点处

        //自定义验证规则
        form.verify({
            title: function(value){
                if(value.length < 2){
                    return '标题至少得2个字符啊';
                }
            }
        });

  //设定文件大小限制
  upload.render({
    elem: '#test7'
    ,url: '<?php echo url('admin/Webconfig/upload'); ?>'
    ,size: 500 //限制文件大小，单位 KB
    ,done: function(res){
        if(res.code == 0){
            $('#typeimg').val(res.data.src);
        }else{
            layer.alert(res.msg, {
                title: '上传失败'
            });
        }
      //console.log(res.path)
    }
  });

        //监听指定开关
      form.on('submit(demo1)', function(data) {
        $.post('<?php echo url('edit'); ?>', $('#editform').serialize(),
          function(data) {
            if (data.code == 1) {
              layer.alert(data.msg, {
                skin: 'layui-layer-molv' //样式类名
                  ,
                closeBtn: 0
              }, function() {
                location.href = data.url;
              });
            } else {
              layer.msg(data.msg);
            }
          });
        return false;
      });


    });
</script>
</body>
</html>